﻿carn_rape_interaction = {
	category = interaction_category_prison

	desc = carn_rape_interaction_desc
	interface_priority = 30
	use_diplomatic_range = no

	is_shown = {
        NOT = { has_game_rule = carn_sex_interaction_disabled }
		has_game_rule = carn_content_consent_noncon
		scope:recipient.location = scope:actor.location
		scope:actor = {
			is_adult = yes
			is_male = yes
            NOR = {
                has_trait_with_flag = carn_block_send_sex_interaction
                has_character_flag = carn_block_send_sex_interaction
                has_character_flag = carn_sex_interaction_effect_cd
                has_opinion_modifier = {
                    target = scope:recipient
                    modifier = carn_block_sex_interaction_to_opinion
                }
            }
		}
		scope:recipient = {
			is_adult = yes
			is_female = yes
			is_pregnant = no 
			fertility > 0
			has_trait = beauty_good 
			#is_imprisoned_by = scope:actor
            NOR = {
				is_close_or_extended_family_of = scope:actor  
                has_trait_with_flag = carn_block_receive_sex_interaction
                has_character_flag = carn_block_receive_sex_interaction
                has_opinion_modifier = {
                    target = scope:actor
                    modifier = carn_block_sex_interaction_from_opinion
                }
            }
		}
	}

	cooldown = { months = carn_sex_interaction_cooldown }

	is_valid_showing_failures_only = {
		scope:actor = {
			carn_can_have_sex_trigger = yes
		}
		scope:recipient = {
            carn_can_be_raped_trigger = yes
		}
		scope:recipient = {
			custom_description = {
				text = "currently_being_tortured"
				NOT = { has_character_flag = is_being_tortured }
			}
		}
	}

	on_accept = {


		scope:actor = {
			if = {
				limit = {
					NOT = { has_character_flag = carn_sex_interaction_effect_cd }
				}

				#Show possible Effects from sex scene
				show_as_tooltip = {
					carn_had_sex_with_effect_v2 = {
						PARTNER = scope:recipient
					}
				}

				#executing the effect rather than only showing, so no need to rerun it from the events
				carn_rape_effect_v2 = {
					VICTIM = scope:recipient
				}
				

				

				add_character_flag = {
					flag = carn_sex_interaction_effect_cd
					months = carn_sex_interaction_cooldown_base
				}
			}
			else = {
				custom_tooltip = carn_sex_interaction_effect_cd_tt
			}}

			hidden_effect = {
				if = {
					limit = { is_ai = no }
					carn_sex_scene_is_noncon_effect = yes
					carn_sex_scene_character_is_giving_player_effect = yes
					carn_sex_scene_character_is_dom_player_effect = yes
					random_list = {
						60 = {
							carn_sex_scene_is_vaginal_effect = yes
							carn_sex_scene_is_cum_inside_effect = yes
						}
						20 = {
							carn_sex_scene_is_vaginal_effect = yes
							carn_sex_scene_is_cum_outside_effect = yes
						}
						10 = {
							trigger = { has_game_rule = carn_content_anal_enabled }
							carn_sex_scene_is_anal_effect = yes
						}
						10 = {
							carn_sex_scene_is_oral_effect = yes
						}
					}
					carn_sex_scene_effect_v2 = {
						PARTNER = scope:recipient
					}
				}
				if = {
					limit = { scope:recipient = { is_ai = no } }
					scope:recipient = {
						carn_sex_scene_is_noncon_effect = yes
						carn_sex_scene_character_is_receiving_player_effect = yes
						carn_sex_scene_character_is_sub_player_effect = yes
						random_list = {
							60 = {
								carn_sex_scene_is_vaginal_effect = yes
								carn_sex_scene_is_cum_inside_effect = yes
							}
							20 = {
								carn_sex_scene_is_vaginal_effect = yes
								carn_sex_scene_is_cum_outside_effect = yes
							}
							10 = {
								trigger = { has_game_rule = carn_content_anal_enabled }
								carn_sex_scene_is_anal_effect = yes
							}
							10 = {
								carn_sex_scene_is_oral_effect = yes
							}
						}
						# actually fire the sex scene
						carn_sex_scene_effect_v2 = {
							PARTNER = scope:actor
						}
					}
				}
			}
		}


	auto_accept = yes
	
	# AI
	ai_targets = {
		ai_recipients = prisoners
		max = 5
	}
	ai_targets = {
		ai_recipients = known_secrets
		max = 5
	}
	ai_targets = {
		ai_recipients = realm_characters
		max = 5
	}
	ai_targets = {
		ai_recipients = hooked_characters
		max = 5
	}
	ai_frequency = 12
	
	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 0

		modifier = {
			has_trait = lustful
			add = 30
		}
		modifier = {
			has_trait = sadistic
			add = 30
		}
		ai_value_modifier = {
			ai_compassion = tiny_chance_impact_negative_ai_value #Adds +50 for highly uncompassionate characters, -50 for highly compassionate characters
		}
		opinion_modifier = {
			opinion_target = scope:recipient
			multiplier = -0.5
		}
	}
}
